/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.component.gateway.dianlan.protocol.passive;

import info.peigen.hotpot.component.gateway.dianlan.annotations.DianlanProtocol;
import info.peigen.hotpot.component.gateway.dianlan.facade.enums.DianlanBatteryPackProperty;
import info.peigen.hotpot.component.gateway.dianlan.facade.enums.DianlanBatteryType;
import info.peigen.hotpot.component.gateway.dianlan.facade.enums.DianlanBmsProtocolVersion;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import lombok.experimental.FieldDefaults;
import lombok.experimental.SuperBuilder;

import static info.peigen.hotpot.component.gateway.dianlan.annotations.DianlanProtocol.DianlanProtocolDataType.*;

/**
 * <b>(DianlanChargingHandshake)</b>
 * <p>
 * 充电握手,GBT-27930 充电桩与 BMS 充电握手阶段报文
 * 帧类型码 0x15
 * 序列号域 0015
 * 数据长度 77
 * 帧校验域 FED2
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2022/8/19
 */
@SuperBuilder
@Data
@NoArgsConstructor
@AllArgsConstructor
@FieldDefaults(level = AccessLevel.PRIVATE)
@Accessors(chain = true)
public class DianlanChargingHandshake {
    /** 交易流水号 */
    @DianlanProtocol(length = 16, start = 0, end = 16, dataType = BCD)
    String                     transNo;
    /** 桩编码 */
    @DianlanProtocol(length = 7, start = 16, end = 23, dataType = BCD)
    String                     stubNo;
    /** 充电枪号 */
    @DianlanProtocol(length = 1, start = 23, end = 24, dataType = BCD)
    String                     chargingPortNo;
    /** BMS 通信协议版本号 */
    @DianlanProtocol(length = 3, start = 24, end = 27, dataType = ENUM)
    DianlanBmsProtocolVersion  bmsProtocolVersion;
    /** BMS 电池类型 */
    @DianlanProtocol(length = 1, start = 27, end = 28, dataType = ENUM)
    DianlanBatteryType         batteryType;
    /** BMS 整车动力蓄电池系统额定容量 0.1 Ah /位，0 Ah 偏移量 */
    @DianlanProtocol(length = 2, start = 28, end = 30, dataType = BIN)
    String                     ratedCapacity;
    /** BMS 整车动力蓄电池系统额定总电压 0.1V/位，0V 偏移量 */
    @DianlanProtocol(length = 2, start = 30, end = 32, dataType = BIN)
    String                     ratedTotalVoltage;
    /** BMS 电池生产厂商名称 */
    @DianlanProtocol(length = 4, start = 32, end = 36, dataType = BIN)
    String                     batteryManufacturerName;
    /** BMS 电池组序号 */
    @DianlanProtocol(length = 4, start = 36, end = 40, dataType = BIN)
    String                     batteryNo;
    /** 电池组生产日期-年 */
    @DianlanProtocol(length = 1, start = 40, end = 41, dataType = BIN)
    String                     manufactureYear;
    /** 电池组生产日期-月 */
    @DianlanProtocol(length = 1, start = 41, end = 42, dataType = BIN)
    String                     manufactureMonth;
    /** 电池组生产日期-日 */
    @DianlanProtocol(length = 1, start = 42, end = 43, dataType = BIN)
    String                     manufactureDay;
    /** 电池组充电次数,1 次/位，0 次偏移量，以 BMS 统计为准 */
    @DianlanProtocol(length = 3, start = 43, end = 46, dataType = BIN)
    String                     batteryPackChargingCount;
    /** BMS 电池组产权标识 */
    @DianlanProtocol(length = 1, start = 46, end = 47, dataType = ENUM)
    DianlanBatteryPackProperty batteryPackProperty;
    /** 预留位 */
    @DianlanProtocol(length = 1, start = 47, end = 48, dataType = BIN)
    String                     reservePlace;
    /** BMS 车辆识别码 VIN */
    @DianlanProtocol(length = 17, start = 48, end = 65, dataType = BIN)
    String                     vin;
    /**
     * BMS 软件版本号
     * Byte8、byte7、byte6—000001H～FFFFFEH，预留，填 FFFFFFH；
     * Byte5-byte2 作为 BMS 软件版本编译时间信息标记，
     * Byte5，byte4—0001H～FFFEH 表示“年”（例如 2015 年：填写Byte5—DFH， byte4—07H）；
     * Byte3—01H～0CH 表示“月”（例如 11 月：填写 Byte3—0BH）；
     * Byte2—01H～1FH 表示“日”（例如 10 日：填写 Byte2—0AH）；
     * Byte1—01H～FEH 表示版本流水号（例如 16：填写 Byte1—10H）
     */
    @DianlanProtocol(length = 17, start = 47, end = 64, dataType = BIN)
    String                     programVersion;

}